package homework.level01model04.homework04;

import java.io.Serializable;
import java.util.Objects;

public class UserMessage implements Serializable {
   /*
   *  其中 UserMessage 类的特征有：类型(字符串类型) 和 用户对象(User 类型)。
  其中 User 类的特征有：用户名、密码(字符串类型)。
  如： UserMessage tum = new UserMessage("check", new User("admin", "123456"));
   *
   * */

    private  String type;
    private  User user;

    public UserMessage() {
    }

    public UserMessage(String type, User user) {
        setType(type);
        setUser(user);
    }

    public void setType(String type) {
        this.type = type;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getType() {
        return type;
    }

    public User getUser() {
        return user;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserMessage that = (UserMessage) o;
        return Objects.equals(type, that.type) &&
                Objects.equals(user, that.user);
    }

    @Override
    public int hashCode() {
        return Objects.hash(type, user);
    }

    @Override
    public String toString() {
        return "UserMessage{" +
                "type='" + type + '\'' +
                ", user=" + user +
                '}';
    }


}
